package com.cm.stock.manager.service;

import java.util.Date;
import java.util.List;

import com.cm.stock.manager.dao.CommandeDAO;
import com.cm.stock.manager.dto.ClientDTO;
import com.cm.stock.manager.dto.CommandeDTO;
import com.cm.stock.manager.dto.UserDTO;

public class CommandeService {
	
	private CommandeDAO commandeDAO;
	
	public CommandeDTO getCommandeByCode (String code){
		return commandeDAO.getByCode(code);
	}
	
	public CommandeDTO saveCommande (double montantbrut, double montantnet, Date dateedition, Date daterendezvous, ClientDTO client, UserDTO user){
		String code = commandeDAO.getMaxId()+"";
		return commandeDAO.save(new CommandeDTO(code, montantbrut, montantnet, dateedition, daterendezvous, client, user));
	}
	
	public CommandeDTO updateCommande (CommandeDTO commande){
		return commandeDAO.update(commande);
	}
	
	public void deleteClient (Integer id) throws Exception{
		commandeDAO.deleteOne(id);
	}
	
	public List<CommandeDTO> getCommandeByDateRendezVous (Date daterendezvous){
		return commandeDAO.getByDateRendezVous(daterendezvous);
	}

	public void setCommandeDAO(CommandeDAO commandeDAO) {
		this.commandeDAO = commandeDAO;
	}
	
	
	
}
